package com.hd.controller;

import com.hd.controller.base.BaseController;
import com.hd.entity.activiti.BaseVO;
import com.hd.entity.sys.User;
import com.hd.service.activiti.ActivitiService;
import com.hd.util.result.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/index")
public class IndexController extends BaseController{
	@Autowired
	private ActivitiService activitiService;
	/**
	 * 主页
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/home")
	public String index(Model model) throws Exception {
		return "jsp/home";
	}

	@ResponseBody
	@RequestMapping("/getDataInfo")
	public Object getDataInfo()throws Exception{
		Map<String,Object> objMap=new HashMap<String,Object>();
		String userId =getUserId();
		User user = new User();
		user.setId(userId);
		Page<BaseVO> p = new Page<BaseVO>(1, 10);
		List<BaseVO> taskList = this.activitiService.findTodoTask(user, p);
		//待办流程总数
		objMap.put("TodoTaskCount", p.getTotal());
		List<BaseVO> processList = this.activitiService.findFinishedTaskInstances(user,p);
		//已办流程总数
		objMap.put("finishTaskCount", p.getTotal());
		return objMap;
	}
}
